package com.itheima.mall.web.cms;

import com.itheima.mall.pojo.cms.Subject;

import com.itheima.mall.service.cms.SubjectService;
import com.itheima.mall.vo.PageResult;
import com.itheima.mall.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("subject")
public class SubjectController {

    @Autowired
    private SubjectService subjectService;

  /* *
     * 根据专题名称分页获取商品专题
     * @param keyword  专题名称
     * @param pageNum  请求的第几页
     * @param pageSize 这一页有多少个product产品
     * @return
*/

    @GetMapping("list")
    public R listByName(String keyword,
                        @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                        @RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize){
        PageResult result=subjectService.listByName(keyword,pageNum,pageSize);
        return R.succeed(result,null);
    }

 /*   *
     * 获取全部商品专题
     * @return

*/
    @GetMapping("listAll")
    public R listAll(){
        List<Subject> subjectList = subjectService.listAll();
        return R.succeed(subjectList,null);
    }


}
